package com.umeox.watch.httpclient.core.client;


import com.umeox.watch.httpclient.core.constant.Scheme;
import com.umeox.watch.httpclient.core.exception.SdkException;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;

public class HttpClientBuilderParams extends BaseClientInitialParam {
    SSLSocketFactory sslSocketFactory = null;
    X509TrustManager x509TrustManager = null;
    HostnameVerifier hostnameVerifier = null;

    public HttpClientBuilderParams() {
    }

    @Override
    public void check() {
        super.check();
        if (Scheme.HTTPS == this.scheme && (null == this.sslSocketFactory || null == this.x509TrustManager || null == this.hostnameVerifier)) {
            throw new SdkException("http channel need sslSocketFactory amd x509TrustManager and hostnameVerifier for communication");
        }
    }

    public SSLSocketFactory getSslSocketFactory() {
        return this.sslSocketFactory;
    }

    public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) {
        this.sslSocketFactory = sslSocketFactory;
    }

    public X509TrustManager getX509TrustManager() {
        return this.x509TrustManager;
    }

    public void setX509TrustManager(X509TrustManager x509TrustManager) {
        this.x509TrustManager = x509TrustManager;
    }

    public HostnameVerifier getHostnameVerifier() {
        return this.hostnameVerifier;
    }

    public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
        this.hostnameVerifier = hostnameVerifier;
    }

}
